#include<iostream>
using namespace std;
int main()
{
	int a,b,c,out;
	cin>>a>>b>>c;
	for(int people=0;people<=100;people++)
	{
		if((a==(people%3))&&(b==(people%5))&&(c==(people%7)))
		{
			out=people;
		}
	}
	cout<<out<<endl;
} 
